// function * foo() {
//     console.log('zce')
//     return 100
// }

// const res = foo();
// console.log(res.next());

// function * foo() {
//     console.log('111')
//     yield 100
//     console.log('222')
//     yield 200
//     console.log(33)
//     yield 300
// }

// const generator = foo()

// console.log(generator.next());
// console.log(generator.next());
// console.log(generator.next());

// 案例1：发号器
function * createIdMaker() {
    let id = 1
    while (true) {
        yield id++
    }
}

const idMaker = createIdMaker()
console.log(idMaker.next().value);
console.log(idMaker.next().value);
console.log(idMaker.next().value);
console.log(idMaker.next().value);